/**
 * 
 */
package org.dragonfire.editor.z80.hiliteRules;

import org.eclipse.jface.text.rules.ICharacterScanner;
import org.eclipse.jface.text.rules.IRule;
import org.eclipse.jface.text.rules.IToken;
import org.eclipse.jface.text.rules.Token;

/**
 * @author Darth Android
 * @date Oct 2, 2007
 */
public class ColumnWrapperRule implements IRule {

	private IRule rule;
	private int endCol;
	private int startCol;

	public ColumnWrapperRule(IRule myRule, int startCol, int endCol) {
		rule = myRule;
		this.startCol = startCol;
		this.endCol = endCol;
	}

	public IToken evaluate(ICharacterScanner scanner) {
		if (!(startCol > 0 && startCol <= scanner.getColumn()) && !(endCol > 0 && scanner.getColumn() <= endCol))
			return Token.UNDEFINED;
		return rule.evaluate(scanner);
	}
}
